package cn.signalpha.modules.base.service;

import cn.signalpha.core.mp.base.BaseServiceImpl;
import cn.signalpha.core.tool.utils.StringUtil;
import cn.signalpha.modules.base.entity.Help;
import cn.signalpha.modules.base.mapper.HelpMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

import static cn.signalpha.common.cache.CacheNames.HELP_KEY;
import static cn.signalpha.common.cache.CacheNames.EXPIRATION_TIME;

/**
 * 服务类
 *
 * @author signalpha
 */
@Service
public class HelpService extends BaseServiceImpl<HelpMapper, Help> {

	@Cacheable(cacheNames = HELP_KEY + EXPIRATION_TIME, key = "#code")
	public List<Help> listCache(String code) {
		return list(Wrappers.<Help>lambdaQuery().eq(StringUtil.isNotBlank(code), Help::getCode, code).orderByDesc(Help::getSort));
	}

	@CacheEvict(cacheNames = HELP_KEY, allEntries = true)
	public void removeCaChe() {
	}

}

